home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_005 / print.support / print.support.c
C/C++ Source or Header  |  1992-05-06  |  5KB  |  132 lines

  1. /*
  2.  *
  3.  *    DISCLAIMER:
  4.  *
  5.  *    This program is provided as a service to the programmer
  6.  *    community to demonstrate one or more features of the Amiga
  7.  *    personal computer.  These code samples may be freely used
  8.  *    for commercial or noncommercial purposes.
  9.  * 
  10.  *     Commodore Electronics, Ltd ("Commodore") makes no
  11.  *    warranties, either expressed or implied, with respect
  12.  *    to the program described herein, its quality, performance,
  13.  *    merchantability, or fitness for any particular purpose.
  14.  *    This program is provided "as is" and the entire risk
  15.  *    as to its quality and performance is with the user.
  16.  *    Should the program prove defective following its
  17.  *    purchase, the user (and not the creator of the program,
  18.  *    Commodore, their distributors or their retailers)
  19.  *    assumes the entire cost of all necessary damages.  In 
  20.  *    no event will Commodore be liable for direct, indirect,
  21.  *    incidental or consequential damages resulting from any
  22.  *    defect in the program even if it has been advised of the 
  23.  *    possibility of such damages.  Some laws do not allow
  24.  *    the exclusion or limitation of implied warranties or
  25.  *    liabilities for incidental or consequential damages,
  26.  *    so the above limitation or exclusion may not apply.
  27.  *
  28.  */
  29.  
  30. #include        "exec/types.h"
  31. #include        "exec/nodes.h"
  32. #include        "exec/lists.h"
  33. #include        "exec/ports.h"
  34. #include        "exec/tasks.h"
  35. #include        "exec/io.h"
  36. #include        "devices/printer.h"
  37. #include     "local.h"
  38.  
  39. /* OPEN THE PRINTER */
  40. int
  41. OpenPrinter(request)
  42.         union printerIO *request;
  43.         {
  44.                 return(OpenDevice("printer.device",0,request,0));
  45.         }
  46.  
  47. /* CLOSE THE PRINTER */
  48.     int
  49. ClosePrinter(request)
  50.     union printerIO *request;
  51.     {
  52.         CloseDevice(request);
  53.         return(0);
  54.     }
  55.  
  56.  
  57. /* Send a NULL terminated string to the printer */
  58.         /* Assumes printer device is open and printerMsg
  59.          * is correctly initialized.  Watches for embedded
  60.          * "escape-sequences" and handles them as defined.
  61.          */
  62.  
  63.     int
  64. PrintString(request,string)
  65.     char *string;
  66.         union printerIO *request;
  67.         {
  68.                 request->ios.io_Command = CMD_WRITE;
  69.                 request->ios.io_Data = string;
  70.                 request->ios.io_Length = -1;
  71.                         /* if -1, the printer assumes it has been given
  72.                          * a null terminated string.
  73.                          */
  74.                 return(DoIO(request));
  75.         }
  76.  
  77.         /* Send RAW character stream to the printer directly,
  78.          * avoid "escape-sequence" parsing by the device.
  79.          */
  80.         
  81.         int
  82. PrintRaw(request,buffer,count)
  83.         char *buffer;           /* where is the output stream of characters */
  84.         union printerIO *request;  /* a properly initialized request block */
  85.         int count;              /* how many characters to output */
  86.         {
  87.                 /* queue a printer raw write */
  88.                 request->ios.io_Command = PRD_RAWWRITE;
  89.                 request->ios.io_Data = buffer;
  90.                 request->ios.io_Length = count;
  91.                 return(DoIO(request));
  92.         }
  93.         int
  94. PrintCommand(request,command, p0, p1, p2, p3)
  95.         union printerIO *request;
  96.         int command, p0, p1, p2, p3;    /* command and its parameters */
  97.         {
  98.                 /* queue a printer command */
  99.                 request->iopc.io_Command = PRD_PRTCOMMAND;
  100.                 request->iopc.io_PrtCommand = command;
  101.                 request->iopc.io_Parm0 = p0;
  102.                 request->iopc.io_Parm1 = p1;
  103.                 request->iopc.io_Parm2 = p2;
  104.                 request->iopc.io_Parm3 = p3;
  105.                 return(DoIO(request));
  106.         }
  107.         int
  108. DumpRPort(request,rastPort, colorMap, modes, sx,sy, sw,sh, dc,dr, s)
  109.                 union printerIO *request;
  110.                 struct RastPort *rastPort;
  111.                 struct ColorMap *colorMap;
  112.                 ULONG modes;
  113.                 UWORD sx, sy, sw, sh;
  114.                 LONG dc, dr;
  115.                 UWORD s;
  116.         {
  117.                 request->iodrp.io_Command = PRD_DUMPRPORT;
  118.                 request->iodrp.io_RastPort = rastPort;
  119.                 request->iodrp.io_ColorMap = colorMap;
  120.                 request->iodrp.io_Modes = modes;
  121.                 request->iodrp.io_SrcX = sx;
  122.                 request->iodrp.io_SrcY = sy;
  123.                 request->iodrp.io_SrcWidth = sw;
  124.                 request->iodrp.io_SrcHeight = sh;
  125.                 request->iodrp.io_DestCols = dc;
  126.                 request->iodrp.io_DestRows = dr;
  127.                 request->iodrp.io_Special = s;
  128.                 return(DoIO(request));
  129.         }
  130.  
  131.  
  132.